//
//  UILabel+Extension.swift
//  sina
//
//  Created by 江先铨 on 15/11/13.
//  Copyright © 2015年 jxqstatic. All rights reserved.
//

import UIKit


extension UILabel {

    convenience init (title: String, size: CGFloat, color: UIColor, margin: CGFloat = 0){  //在这里需要设置间隔  默认为 0 的话可以不传递任何的参数
        
       self.init()
        
        text = title
        
      textAlignment = NSTextAlignment.Center
        
       font = UIFont.systemFontOfSize(size)
        
        textColor = color
        
        numberOfLines = 0
        
        if margin != 0 {
           //最大的布局的宽度
           preferredMaxLayoutWidth = screenW - 2 * margin
           //坐对齐
           textAlignment = .Left
        }
        
        sizeToFit()
        
    }
}